I need help! Bug problem. As I was correcting the MDIChild bug issue reported by ubt1 and seems to have corrected it, another problem occurs, crash problem! As I analyzed my code, I find nothing that could interrupt or cause the subclasser to get into trouble. It went all fine until terminating (or unsubclassing) the WM_NCACTIVATE message I added to subclass the parent form. I tried almost anything until I got a crazy idea of why not testing the subclass examples itself provided by Paul Caton on his SelfSub v2.1 submission particularly the pSample.vbp project on \Samples\uSelfSub\Simple directory.
The following are the steps seconds from disaster :)
15. Add MDI form to the project then set it as the Startup object.
14. Set the existing fMain form to be its MDIChild.
13. On MDI Form_Load() procedure I added the line "fMain.Show" (without the quotes of course) only.
12. I test run it and it went fine.
11. Next I forgot, on the uSample.ctl usercontrol code particularly on the UserControl_ReadProperties() procedure...
10. I added the line "sc_AddMsg .hwnd, &H86" (without the quotes) as the last code inside the UserControl.Parent WITH structure
09: By the way, &H86 is the API constant value for WM_NCACTIVATE
08. The procedure should look like this below:
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
#OTHER CODES TRUNCATED#
With UserControl.Parent
sc_Subclass .hwnd
sc_AddMsg .hwnd, WM_MOVING
sc_AddMsg .hwnd, WM_SIZING
sc_AddMsg .hwnd, WM_EXITSIZEMOVE
sc_AddMsg .hwnd, &H86 ' WM_NCACTIVATE
End With
End Sub
07. Then I run it again. It went fine again! (Almost losing hope, I got another hint.)
06. I created another instance of the uSample usercontrol on the fMain form.
05. I run it again and close the form by form's close button or the MDI's close button but still it went fine.
04. Got really prostrated, I added another instance of the uSample usercontrol on the fMain form.
03. The form (fMain) now contains a total of 3 uSample usercontrol objects.
02. Now I run it.
01. It went fine again!!!
00. Feeling really helpless, I closed the MDI form using the close button of the MDI form. Got yah!!! VB crashes!!!
I open it again and follow the same steps again to be sure that I wasn't having mistakes and still it crashes.
Now I'm quite confident that it wasn't my code that causes the ugly crash. The subclasser itself has the problem.
I need help from Paul Caton who is the original author of the great self-subclasser or anyone who can to solve this problem.
And hey before I forgot, previous versions (not sure what version) of Paul Caton's subclasser does not experience this problem.
To make things easier, I incuded the sample project on this submission. It is located on the this folder.
|